package com.ctshk.sapp.hotel.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.hotel.dto.*;
import com.ctshk.rpc.hotel.dto.booking.HotelBookingDetailsDTO;
import com.ctshk.rpc.hotel.req.*;
import com.ctshk.rpc.hotel.req.booking.HotelDetailsQueryReq;
import com.ctshk.rpc.hotel.service.IChimeLongAPIService;
import com.ctshk.rpc.hotel.service.IHotelService;
import com.ctshk.rpc.hotel.service.INCNBHotelService;
import com.ctshk.rpc.hotel.service.IWestMinisterHotelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @description 酒店管理-预订中心
 * @author 谢诗宏
 * @date 2021/5/6
 */
@RestController
@Api(value = "酒店管理-预订中心", tags = "预订中心")
@RequestMapping("/booking")
public class HotelBookingController extends BaseController {
    @DubboReference
    private IHotelService hotelService;
    @DubboReference
    private IChimeLongAPIService chimeLongAPIService;
    @DubboReference
    private INCNBHotelService ncnbHotelService;
    @DubboReference
    private IWestMinisterHotelService westMinisterHotelService;

    @ApiOperation(value="酒店列表搜索", notes="酒店列表搜索-预订中心")
    @OperationLogAnnotation(operModul = OperationLogModel.HOTEL, operType = OperationLogType.QUERY, operTitle = "酒店列表搜索", operDesc = "酒店列表搜索")
    @PostMapping("/search")
    public Result<PageResponse<HotelQueryListDTO>> queryList(@RequestBody @Valid HotelOrderQueryReq req) {
        PageResponse<HotelQueryListDTO> result = hotelService.queryList(req, getCurrentUser(getRequest()).getId());
        return Result.success(result);
    }

    @ApiOperation(value="酒店推薦列表查询", notes="酒店推薦列表查询-预订中心")
    @OperationLogAnnotation(operModul = OperationLogModel.HOTEL, operType = OperationLogType.QUERY, operTitle = "酒店推薦列表查询", operDesc = "酒店推薦列表查询")
    @GetMapping("/recommends")
    public Result<List<HotelQueryListDTO>> recommends() {
        List<HotelQueryListDTO> result = hotelService.queryRecommendationList(getCurrentUser(getRequest()).getId());
        return Result.success(result);
    }

    @ApiOperation(value="酒店预订详情", notes="酒店预订详情-预订中心")
    @OperationLogAnnotation(operModul = OperationLogModel.HOTEL, operType = OperationLogType.QUERY, operTitle = "酒店预订详情", operDesc = "酒店预订详情-预订中心")
    @PostMapping("/details")
    public Result<HotelBookingDetailsDTO> details(@RequestBody @Valid HotelDetailsQueryReq req) {
        return Result.success(hotelService.details(req, getCurrentUser(getRequest()).getId()));
    }

}
